/**
 * util functions
 */

function HashMap(){
    this.Set =  function (key,value){
        this[key] = value;
    };
    this.Get = function(key){
        return this[key];
    };
    this.Remove = function(key){
        delete this[key];
    };
    this.Contains =  function (key) {
        return this.Get(key) == null
            ? false
            : true
    }
}

Date.prototype.Format = function (fmt) { //author: meizz
    var o = {
        "M+": this.getMonth() + 1, //月份
        "d+": this.getDate(), //日
        "h+": this.getHours(), //小时
        "m+": this.getMinutes(), //分
        "s+": this.getSeconds(), //秒
        "q+": Math.floor((this.getMonth() + 3) / 3), //季度
        "S": this.getMilliseconds() //毫秒
    };
    if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
    for (var k in o)
        if (new RegExp("(" + k + ")").test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
    return fmt;
};

function DoubleBubbleSort(arr1,arr2){
    for(var i=0;i<arr1.length;i++){
        for(var j=i;j<arr1.length;j++){
            if(arr1[i]<arr1[j]){
                var temp=arr1[i];
                arr1[i]=arr1[j];
                arr1[j]=temp;

                //second
                var temp2=arr2[i];
                arr2[i]=arr2[j];
                arr2[j]=temp2;

            }
        }
    }
    return {
        'arr1':arr1,
        'arr2':arr2
    };
}

exports.HashMap = HashMap;
exports.Format = Date.Format;
exports.DoubleBubbleSort = DoubleBubbleSort;

